package com.iplant.mes.service.po.sfc;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.pdm.service.basicenum.pdm.PDMComponentTypes;

/**
 * 工装使用记录（托盘、模具）
 *
 * @author YouWang·Peng
 * 2024-4-24 09:22:41
 */
@DBBasePO(TableName = "sfc_tool_usage_record", Name = false, Active = false, Schemas = DBSchemas.MES,
        CheckName = {"Code"}, CodeAuto = true, CodePrefix = "STUR-{yyyyMMdd}-", CodeNum = 4)
public class SFCToolUsageRecord extends BasePO {
    /**
     * 工件记录ID
     */
    @DBCondition
    @DBField
    public int WorkpieceRecordID = 0;

    /**
     * 工件号
     */
    @DBJoin(name = "Code", tableName = "sfc_workpiece_record", tableAsName = "sfc_workpiece_record1", Schemas =
            DBSchemas.MES,
            MainTableField = "WorkpieceRecordID")
    public String WorkpieceCode = "";

    /**
     * 工装台账ID
     */
    @DBField
    public int FrockLedgerID = 0;

    /**
     * 资产ID
     */
    @DBJoin(name = "AssetInfoID", tableName = "dms_frock_ledger", tableAsName = "dms_frock_ledger1", Schemas =
            DBSchemas.AMS,
            MainTableField = "FrockLedgerID")
    public int AssetInfoID = 0;

    /**
     * 工装名称
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "ams_asset_list", tableAsName = "ams_asset_list1", Schemas = DBSchemas.AMS,
            JoinIndex = 2,
            ConditionalJoin = "dms_frock_ledger1.AssetInfoID=ams_asset_list1.ID")
    public String FrockLedgerName = "";

    /**
     * 工装编码
     */
    @DBCondition
    @DBJoin(name = "Code", tableName = "ams_asset_list", tableAsName = "ams_asset_list1", Schemas = DBSchemas.AMS,
            JoinIndex = 2,
            ConditionalJoin = "dms_frock_ledger1.AssetInfoID=ams_asset_list1.ID")
    public String FrockLedgerCode = "";

    /**
     * 工装类型
     */
    @DBCondition
    @DBField
    public int ComponentType = 0;

    /**
     * 工装类型文本
     */
    public String ComponentTypeText = "";

    public SFCToolUsageRecord() {
    }

    public SFCToolUsageRecord(int workpieceRecordID, int frockLedgerID, int componentType) {
        WorkpieceRecordID = workpieceRecordID;
        FrockLedgerID = frockLedgerID;
        ComponentType = componentType;
    }

    @JsonProperty("WorkpieceRecordID")
    public int getWorkpieceRecordID() {
        return WorkpieceRecordID;
    }

    public void setWorkpieceRecordID(int workpieceRecordID) {
        WorkpieceRecordID = workpieceRecordID;
    }

    @JsonProperty("WorkpieceCode")
    public String getWorkpieceCode() {
        return WorkpieceCode;
    }

    public void setWorkpieceCode(String workpieceCode) {
        WorkpieceCode = workpieceCode;
    }

    @JsonProperty("FrockLedgerID")
    public int getFrockLedgerID() {
        return FrockLedgerID;
    }

    public void setFrockLedgerID(int frockLedgerID) {
        FrockLedgerID = frockLedgerID;
    }

    @JsonProperty("AssetInfoID")
    public int getAssetInfoID() {
        return AssetInfoID;
    }

    public void setAssetInfoID(int assetInfoID) {
        AssetInfoID = assetInfoID;
    }

    @JsonProperty("FrockLedgerName")
    public String getFrockLedgerName() {
        return FrockLedgerName;
    }

    public void setFrockLedgerName(String frockLedgerName) {
        FrockLedgerName = frockLedgerName;
    }

    @JsonProperty("FrockLedgerCode")
    public String getFrockLedgerCode() {
        return FrockLedgerCode;
    }

    public void setFrockLedgerCode(String frockLedgerCode) {
        FrockLedgerCode = frockLedgerCode;
    }

    @JsonProperty("ComponentType")
    public int getComponentType() {
        return ComponentType;
    }

    public void setComponentType(int componentType) {
        ComponentType = componentType;
    }

    @JsonProperty("ComponentTypeText")
    public String getComponentTypeText() {
        return PDMComponentTypes.getEnumType(ComponentType).getLabel();
    }

    public void setComponentTypeText(String componentTypeText) {
        ComponentTypeText = componentTypeText;
    }
}
